package com.cehome.cloudbox.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cehome.cloudbox.base.R;
import com.cehome.cloudbox.constans.MsgConstants;
import com.cehome.cloudbox.doman.vo.ProDefExtemdInfo;
import com.cehome.cloudbox.doman.vo.ProcDefExtendQueryVo;
import com.cehome.cloudbox.doman.vo.ProcDefExtendShowVo;
import com.cehome.cloudbox.doman.vo.ProcDefVersionVo;
import com.cehome.cloudbox.entity.ProcDefExtend;
import com.cehome.cloudbox.service.IProcDefExtendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * <p>
 * 流程定义扩展表 控制器
 * </p>
 */
@Api(value = "流程定义扩展表操作API", tags = "工作流设置")
@RestController
@RequestMapping("/procDefExtend")
public class ProcDefExtendController {

    @Autowired
    private IProcDefExtendService iProcDefExtendService;

    @ApiOperation(value = "流程定义扩展表分页查询")
    @GetMapping(value = "/page")
    public Page<ProcDefExtendShowVo> page(ProcDefExtendQueryVo queryVo) {
        Page<ProcDefExtendShowVo> aPage = iProcDefExtendService.page(queryVo);
        return aPage;
    }


    @ApiOperation(value = "查询已发布工作流--流程定义扩展表分页查询")
    @GetMapping(value = "/selectFlowAblePage")
    public Page<ProcDefExtendShowVo> selectFlowAblePage(ProcDefExtendQueryVo queryVo) {
        Page<ProcDefExtendShowVo> aPage = iProcDefExtendService.selectFlowAblePage(queryVo);
        return aPage;
    }


    @ApiOperation(value = "流程定义扩展表集合")
    @GetMapping(value = "/getList")
    public List<ProcDefExtend> getList() {
        List<ProcDefExtend> list = iProcDefExtendService.list();
        return list;
    }

    @ApiOperation(value = "根据ID查询流程定义扩展表")
    @GetMapping(value = "/{id}")
    public ProcDefExtend getById(@PathVariable("id") String id) {
        ProcDefExtend defExtend = iProcDefExtendService.getById(id);
        return defExtend;
    }

    @ApiOperation(value = "新*插入流程定义扩展表")
    @PostMapping(value = "/create")
    public Boolean create(@RequestBody ProDefExtemdInfo defExtemdInfo) {
        return  iProcDefExtendService.saveProcDefExtend(defExtemdInfo);
    }



    @ApiOperation(value = "修改流程定义扩展表")
    @PostMapping(value = "/update")
    public Boolean update(@RequestBody ProDefExtemdInfo defExtemdInfo) {
        return iProcDefExtendService.updateProcDefExtend(defExtemdInfo);
    }

    @ApiOperation(value = "删除流程定义扩展表")
    @PostMapping(value = "/delete/{id}")
    public Boolean delete(@PathVariable("id") Long id) {
        iProcDefExtendService.delete(id);
        return true;
    }

//    @ApiOperation(value = "更新流程定义扩展表")
//    @PostMapping(value = "/update")
//    public R<Boolean> update(@RequestBody ProDefExtemdInfo defExtemdInfo) {
//        iProcDefExtendService.updateById(defExtemdInfo);
//        return R.code(MsgConstants.MSG_C002);
//    }

//    @ApiOperation(value = "发布流程定义扩展表")
//    @PostMapping(value = "/deploy/{id}")
//    public R<Boolean> deploy(@PathVariable("id") Long id) {
//        iProcDefExtendService.deploy(id);
//        return R.ok();
//    }

//    @ApiOperation("流程定义禁用")
//    @PostMapping("/disable/{id}")
//    public R<Boolean> disable(@PathVariable("id") Long id) {
//        iProcDefExtendService.disable(id);
//        return R.ok();
//    }
//
//    @ApiOperation("流程定义启用")
//    @PostMapping("/enable/{id}")
//    public R<Boolean> enable(@PathVariable("id") Long id) {
//        iProcDefExtendService.enable(id);
//        return R.ok();
//    }

}
